/*
 * Rider.java
 *
 * Created on 18. �erven 2007, 20:27
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package cz.possoft.serializable.chess.figurky;

import cz.possoft.generic.utils.GenericUtils;
import cz.possoft.messages.PropertiesManager;
import cz.possoft.messages.Text;
import cz.possoft.serializable.chess.game.ChessPole;

/**
 *
 * @author mara
 */
public class Rider extends Figurka {
	
	public static final long serialVersionUID = 10978799;
    
    public Rider() {        
    }
    
    /** Creates a new instance of Rider */
    public Rider(int x,int y,int color,ChessPole sachovnice) {
        setX(x);
        setY(y);
        setColor(color);
        setSachovnice(sachovnice);
        setMarked(false);
    }
    
    public String getFigurkaName() {
        return PropertiesManager.getInstance().getMessageForKey(Text.JEZDEC);
    }
    
    public boolean muzeTahnout2(int xCil,int yCil) {
        if ((xCil<0)||(xCil>7)||(yCil<0)||(yCil>7)) return false;
        //System.out.println("xCil: " + xCil + ", yCil: " + yCil + ", getX(): " + getX() + ", getY(): " + getY());
        if ((GenericUtils.abs(xCil - getX()) == 1) && (GenericUtils.abs(yCil - getY()) == 2) && (getSachovnice().getFigurka(xCil, yCil).getColor() != getColor())) return true;
        if ((GenericUtils.abs(xCil - getX()) == 2) && (GenericUtils.abs(yCil - getY()) == 1) && (getSachovnice().getFigurka(xCil, yCil).getColor() != getColor())) return true;
       
        return false;
    }
    
}
